﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;

namespace T.FAS.Runtime.Base.Entity
{
    /// <summary>
    /// 数据实体属性
    /// </summary>
    public class TAttribute
    {
        /// <summary>
        /// 元数据Code
        /// </summary>
        public string MetadataCode { get; set; }
        /// <summary>
        /// 来源列的ID
        /// </summary>
        public string SourceColumnID { get; set; }
        /// <summary>
        /// 来源列的Code
        /// </summary>
        public string SourceColumnCode { get; set; }

        /// <summary>
        /// 来源列的Name
        /// </summary>
        public string SourceColumnName { get; set; }
        /// <summary>
        /// 引用路径表达式
        /// </summary>
        public string RefSchemaExpr { get; set; }
        /// <summary>
        /// 列标识
        /// </summary>
        public string ID { get; set; }
        /// <summary>
        /// 列名称
        /// </summary>
        public string Code { get; set; }
        /// <summary>
        /// 中文描述
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 描述信息
        /// </summary>
        public string Description { get; set; }
        /// <summary>
        /// 数据类型
        /// </summary>
        public DataType DataType { get; set; }
        /// <summary>
        /// 原始数据类型,比如DO引用xxxSDO时，DataType字段会找到xxxSDO的主键列类型，OriginDataType则标识xxxSDO
        /// </summary>
        public string OriginDataType { get; set; }
        /// <summary>
        /// 是否主键字段
        /// </summary>
        public bool IsPrimaryKey { get; set; }
        /// <summary>
        /// 序号
        /// </summary>
        public int SortOrder { get; set; }
        /// <summary>
        /// 是否明细节点
        /// </summary>
        public bool IsDetail { get; set; }
        /// <summary>
        /// 是否是虚拟字段，标记为虚拟字段的列，不参与VM实际返回值结构的生成
        /// </summary>
        /// <example>
        /// 数据库表中的外键关联列,比如Department表中的CompanyID列，
        /// </example>
        public bool IsVirtual { get; set; }
        /// <summary>
        /// 关联属性列
        /// </summary>
        public string RelatePropertyCode { get; set; }
        /// <summary>
        /// DataType为Record和List时，子集合的Entity来源
        /// </summary>
        public TEntityType EntityType { get; set; }
        /// <summary>
        /// 当DataType为List或者Record是，子类数据结构
        /// </summary>
        public TEntity Entity { get; set; }
        /// <summary>
        /// 属性字段长度
        /// </summary>
        public int Length { get; set; }
        /// <summary>
        /// 是否必填
        /// </summary>
        public bool IsRequired { get; set; }
        /// <summary>
        /// 精度
        /// </summary>
        public int Precision { get; set; }
        /// <summary>
        /// 默认值
        /// </summary>
        public object DefaultValue { get; set; }
        /// <summary>
        /// 属性字段类型
        /// </summary>
        public TAttributeType AttributeType { get; set; }

        /// <summary>
        /// 扩展属性，用于后续扩展新增的字段属性信息
        /// </summary>
        public Dictionary<string, object> ExtProperties { get; set; }
    }
}
